#include <iostream>
#include <sys/types.h>
#include <signal.h>

int main(int argc, char *argv[])
{
    // 判断参数列表  ./myKill signal pid
    if (argc != 3)
    {
        std::cout << "Usage: ./myKill signal pid" << std::endl;
        exit(-1);
    }
    // 提取信号/pid+转化成整数
    int signal = argv[1][1] - '0';  //"-6" -> 6   //strtol(argv[1], nullptr, 0); 
    std::cout << "siganl " << signal << std::endl;
    int pid = strtol(argv[2], nullptr, 0);
    // 对指定进程发送指定信号
    int result = kill(pid, signal);
    if (result == -1)
    {
        perror("kill fail");
    }


    return 0;
}